package DaEr_5_25;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Random;

public class Test2{
    public static void main(String[] args) {
        Student s1 = new Student("张无忌","男");
        Student s2 = new Student("赵敏","女");
        Student s3 = new Student("小龙女","女");
        Student s4 = new Student("张三丰","男");
        Student s5 = new Student("杨逍","男");
        ArrayList<Student> list = new ArrayList<>();
        Collections.addAll(list,s1,s2,s3,s4,s5);
        Random r = new Random();
        int temp = r.nextInt(10)+1;
        Student s = new Student();
        while (true){
            s=stu(list);
            if (temp<8){
                if (s.getSex().equals("男")) {
                    break;
                }
                }else {
                    if (s.getSex().equals("女")){
                        break;
                    }
                }
            }
            System.out.println(s);



    }
    public static Student stu(ArrayList<Student>list){
        Random r = new Random();
        int index = r.nextInt(list.size());
        return list.get(index);
    }
}
